package main

func main() {

}

//#link: https://leetcode-cn.com/problems/detect-capital/
func detectCapitalUse(word string) (ans bool) {
	firstChar := word[0]
	if isUpper(firstChar) {
		//判断是否全是大写
		// 首字母大写
		allUpper := true
		allLower := true
		for i := 1; i < len(word); i++ {
			// 是否全是大写
			allUpper = allUpper && isUpper(word[i])
			allLower = allLower && !isUpper(word[i])
		}
		return allUpper || allLower
	} else {
		//是否含有大写
		for i := 1; i < len(word); i++ {
			if isUpper(word[i]) {
				return false
			}
		}
	}
	return true
}

func isUpper(s byte) bool {
	return s >= 'A' && s <= 'Z'
}
